<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>注册</title>
		<link rel="stylesheet" type="text/css" href="http://gogok12.com/css/apps.css"/>
		<link rel="stylesheet" type="text/css" href="http://gogok12.com/fonts/iconfont.css"/>
		<style>
			body{
				font-size: 16px;
			}
			#back{
				width: 100%;
				height: .8rem;
				background: #778899;
			}
			#back .icon{
				display: inline-block;
				height: .8rem;
				width: .8rem; 
				/* border-radius:50%; */
				/* background: #FFFDEF; */
				line-height: .8rem;
				text-align: center;
				font-size: .5rem;
				color: #FFFDEF;
			}
			.row{
				margin: 10px 0 10px;
				height: 60px;
				display: flex;
				position: relative;
			}
			.row>label{
				display: inline-block;
				/* border: 1px solid red; */
				color: #0077AA;
				flex:2;
				position: absolute;
				text-align: center;
				line-height: 60px;
				margin-left:0.3125rem;
				/* float: left; */
			}
			.row>input{
				display: inline-block;
				position: absolute;
				left:10%;
				top: 10px;
				flex:8;
				width: 70%;
				outline: none;
				border:none;
				height: 60px;
				outline: none;
				height: 40px;
				margin-left:30px;
				padding-left:15px;
				border-bottom: 2px solid #CCCCCC;
			}
			.reg{
				width: 70%;
				margin:40px auto;
				
			}
			.reg button{
				width: 100%;
				background: -webkit-linear-gradient(left,#ff9000,#ff5000) no-repeat;
				color: #fff;
				box-shadow: 0 2px 4px #f7c7b1;
				border-radius: 35px;
				margin-top: 15px;
				border: 1px solid #ff9000;
				font-size: .32rem;
				height: 42px;
				line-height: 42px;
				outline: none;
				cursor: pointer;
			}
			.radio{
				margin-left:0.3125rem;
				color: #0077AA;
			}
			.radio span{
				color: #333333;
			}
		</style>
		<script src="http://gogok12.com/js/apps.js"></script>
		<script src="http://gogok12.com/chatjs/axios.js"></script>
	</head>
	<body>
		<div id="back">
			<span id="icon" class="icon iconfont">
				&#xe63b;
			</span>
		</div>
		<!-- <form> -->
			<div class="row">
				<label>公司名</label>
				<input type="text" id="company" placeholder="请输入公司名称" name="company_name">
			</div>
			<div class="row">
				<label>产品名</label>
				<input type="text" id="product" placeholder="请输入产品" name='product_name'>
			</div>
			<div class="row">
				<label>用户名</label>
				<input type="text" id="linkman" placeholder="请输入用户名" name="linkman">
			</div>
			<div class="row">
				<label>需&nbsp;&nbsp;&nbsp;求</label>
				<input type="text" id="need" placeholder="请输入您的需求" name="need">
			</div>
			<div class="row">
				<label>手机号</label>
				<input type="text" id="phone" placeholder="请输入手机号" name="phone">
			</div>
			<div class="row">
				<label>密&nbsp;&nbsp;&nbsp;码</label>
				<input type="text" id="pw" placeholder="请输入密码" name="pass_word">
			</div>
			<div class="radio">
				<label>公司类型</label>
				<input type="radio" value="A" name="party" onclick="f(this.value)"> <span>甲方</span>
				<input type="radio" value="B" name="party" onclick="f(this.value)"> <span>乙方</span>
			</div>
			<div class="reg">
				<button id="btn">注册</button>
			</div>
		<!-- </form> -->
	</body>
</html>
<script type="text/javascript" src="http://gogok12.com/js/mui.js">
	
</script>
<script>
	document.getElementById("icon").onclick=function(){
		window.history.go(-1);
	}
	var party1=null;
	function f(v){
		party1=v;
	}
	function $(idname){
		return document.getElementById(idname);
	}
	document.getElementById("btn").onclick=function(){
		var company_name=$("company").value;
		var product_name=$("product").value;
		var linkman=$("linkman").value;
		var need=$("need").value;
		var phone=$("phone").value;
		var pass_word=$("pw").value;
		var party=party1;
		var openid="{{open_id}}"; //给后台添加的
		// var data={company_name,product_name,linkman,need,phone,pass_word,party,openid}
		// console.log(data)
		// mui.ajax('http://gogok12.com/api/v2/company',{
		// 	data:data,
		// 	headers:{'Content-Type':'application/x-www-form-urlencoded'},
		// 	dataType:'json',//服务器返回json格式数据
		// 	type:'post',//HTTP请求类型
		// 	timeout:10000,//超时时间设置为10秒；
		// 	success:function(data){
		// 		// 状态status 为-1 不成功  1是成功的
		// 		console.log(data)
		// 	},
		// 	error:function(xhr,type,errorThrown){
		// 		console.log("xxxx")
		// 	}
		// });
		
		
		
		
		
		
		
		
		
		var param = new URLSearchParams()
		param.append('company_name',company_name)
		param.append('product_name',product_name)
		param.append('linkman',linkman)
		param.append('need',need)
		param.append('phone',phone)
		param.append('pass_word',pass_word)
		param.append('party',party)
		param.append('openid',openid)
		console.log(param)
		var b=axios.post('http://gogok12.com/api/v2/company',param)
			.then(function (response) {
				console.log(response);
				if(response.data.status==1){
					setTimeout(function(){
						location.href="http://gogok12.com/login.html"
					},2000)
				}else{
					alert(response.data.errorMsg)
				}
				
			  })
			  .catch(function (error) {
				console.log(error);
			  });
	}
	// http://gogok12.com/api/v2/openid_callback
	
	
	
	// location.href="https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx90014a2b7a9ab7f2&redirect_uri=http%3A//gogok12.com/apps/register.html&response_type=code&scope=snsapi_base&connect_redirect=1#wechat_redirect"
	// console.log($)
	// "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx90014a2b7a9ab7f2&redirect_uri=http%3A//www.gogok12.com/api/v2/openid_callback&response_type=code&scope=snsapi_base#wechat_redirect"
	// var btn=document.getElementById("btn");
	// var fromurl = location.href;
	// console.log(fromurl)
	// var url="https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx90014a2b7a9ab7f2&redirect_uri="+encodeURIComponent(fromurl)+"&response_type=code&scope=snsapi_base#wechat_redirect";
	// location.href=url;
	 // document.getElementById("btn").onclick=function(){
		 // axios.get("http://gogok12.com/api/v2/openid_callback")
		 // .then(function(res){
		 // 	// alert("111")
		 // 	alert(res.toString())
		 // 	// var url=res.data.resultBody.authorize_url;
		 // 	}).catch(function(err){alert(err);console.log(err)})
	 // }
	
		// https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx90014a2b7a9ab7f2&redirect_uri=http://192.168.1.6:8848/1903B/4.8/apps/index.html&response_type=code&scope=snsapi_base#wechat_redirect
		// btn.onclick=function(){
		// 	// alert(11)
		// 	alert(url)
		// 	axios.get(url)
		// 	.then(function(res1){
		// 		console.log(res1)
		// 		document.getElementById("div").innerHTML=res1;
		// 		alert(res1.resultBody.open_id)
		// 	}).catch(function(err){alert(err)})
		// }
		
	// }).catch(function(err){alert(err)})
                  // https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri = REDIRECT_URL&response_type=code&scope=SCOPE&state=STATE#wechat_redirect
	// var target = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx90014a2b7a9ab7f2&redirect_uri=http%3A//www.gogok12.com/api/v2/openid_callback&response_type=code&scope=snsapi_base#wechat_redirect";
	// $.ajax({//2.通过code换取网页授权access_token
	// 	type:"get",
	//     url: 'http://query.yahooapis.com/v1/public/yql',//雅虎代理url
	// 	async:true,
	//     dataType: "jsonp",//雅虎代理数据格式
	//     data:{
	//         q:"select * from json where url=\'"+target+"'",
	//         //代理返回格式
	//         format:"json"
	//     },
	//     success: function (data) {
	//         alert("请求成功");
	//         // alert("openid:"+data.query.results.json.openid);
	//         // console.log("openid:"+data.query.results.json.openid);
	//     },
	// 	error:function(err){
	// 		alert(111)
	// 	}
	// });
</script>
<!-- {"errorCode":null,"errorMsg":null,"resultBody":{"open_id":"o8keB56_H9ApyraE_W1H_M1DtLEQ"},"status":1} -->